import request from '@/utils/request'

// 新增数据源
export function saveDataSource(data) {
    return request({
        url: '/datasource',
        method: 'post',
        headers: {
            'Content-Type': 'application/json'
        },
        data
    })
}

// 删除数据源
export function removeDataSource(id) {
    return request({
        url: '/datasource/' + id,
        method: 'delete'
    })
}

// 修改数据源
export function updateDataSource(id, data) {
    return request({
        url: '/datasource/' + id,
        method: 'put',
        headers: {
            'Content-Type': 'application/json'
        },
        data
    })
}

// 查询数据源
export function listDataSource(query) {
    return request({
        url: '/datasource',
        method: 'get',
        params: query
    })
}

// 数据源列表
export function listAllDataSource(query) {
    return request({
        url: '/datasource/list',
        method: 'get',
        params: query
    })
}

// 查询数据库表信息
export function listTableInfo(query) {
    return request({
        url: '/datasource/table',
        method: 'get',
        params: query
    })
}

// 测试连接
export function connection(id) {
    return request({
        url: '/datasource/connection/' + id,
        method: 'post'
    })
}
